
const { ccclass, property } = cc._decorator;

import MoFenDi from "./MoFenDi";
import CaLian from "./CaLian";
import GaoGuang from "./GaoGuang";
@ccclass
export default class StepTwo extends cc.Component {
    //触摸区域
    @property(cc.Node)
    bg: cc.Node = null;
    //第二步
    //抹粉底
    @property(MoFenDi)
    MoFenDi: MoFenDi = null;
    //擦脸
    @property(CaLian)
    CaLian: CaLian = null;
    //阴影
    @property(GaoGuang)
    YinYing: GaoGuang = null;
    //高光
    @property(GaoGuang)
    GaoGuang: GaoGuang = null;

    _point = 1;
    onLoad() {
        this.bg.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.bg.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.bg.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
    };

    onTouchStart(event) {
        switch (this._point) {
            case 1:
                this.MoFenDi._touchStart(event);
                break;
            case 2:
                this.CaLian._touchStart(event);
                break;
            case 3:
                this.YinYing._touchStart(event, "yinying");
                break;
            // case 4:
            //     this.GaoGuang._touchStart(event);
            //     break;
        }
    };

    onTouchMove(event) {
        switch (this._point) {
            case 1:
                this.MoFenDi._touchMove(event);
                break;
            case 3:
                this.YinYing._touchMove(event);
                break;
            // case 4:
            //     this.GaoGuang._touchMove(event);
            //     break;
        }
    };

    onTouchEnd(event) {
        switch (this._point) {
            case 2:
                this.CaLian._touchEnd(event);
                break;
            case 3:
                this.YinYing._touchEnd(event, "yinying");
                break;
            // case 4:
            //     this.GaoGuang._touchEnd(event, "gaoguang");
            //     break;
        }
    };

    //更新步骤
    updatePoint(point: number) {
        this._point = point;
        this.MoFenDi.node.active = point == 1;
        this.CaLian.node.active = point == 2;
        this.YinYing.node.active = point == 3;
        // this.GaoGuang.node.active = point == 4;
        switch (point) {
            case 1:
                this.MoFenDi.initData();
                break;
            case 2:
                this.CaLian.initData();
                break;
            case 3:
                this.YinYing.initData();
                break;
            // case 4:
            //     this.GaoGuang.initData();
            //     break;
        }
    };


}
